# coding=utf-8
import random

x = 'y'
while x == 'y':
    result = random.randint(1, 100)
    sum = 0
    print 'Enter coins that add up to %s cents, one per line.' % result
    x = raw_input('Enter first coin:')

    while x:
        if not x in ['1', '5', '25']:
            print 'Invalid entry'
            x = raw_input('Enter next coin:')
            continue

        else:
            sum += eval(x)
            if sum > result:
                print 'Sorry - total amount exceeds %s cents.\n' % result
                break
        x = raw_input('Enter next coin:')

    if sum == result:
        print 'Correct!\n'
    elif sum < result:
        print 'Sorry - you only entered %s cents.\n' % sum

    while True:
        x = raw_input('Try again(y/n)?:')
        if x in ['y', 'n']:
            if x == 'y':print '\n',
            break

print 'Thank you for playing ... goodbye'

## output:
# Enter coins that add up to 56 cents, one per line.
# Enter first coin:25
# Enter next coin:25
# Enter next coin:3
# Invalid entry
# Enter next coin:1
# Enter next coin:5
# Enter next coin:
# Correct!
# 
# Try again(y/n)?:y
# 
# Enter coins that add up to 65 cents, one per line.
# Enter first coin:25
# Enter next coin:25
# Enter next coin:25
# Sorry - total amount exceeds 65 cents.
# 
# Try again(y/n)?:y
# 
# Enter coins that add up to 65 cents, one per line.
# Enter first coin:25
# Enter next coin:25
# Enter next coin:5
# Enter next coin:5
# Enter next coin:
# Sorry - you only entered 60 cents.
# 
# Try again(y/n)?:n
# Thank you for playing ... goodbye